<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<link type="text/css" rel="stylesheet" href="resource/css/default.css" />
</h:head>

<h:body>
<h:form enctype="multipart/form-data">

	<p:layout fullPage="true">
	
		<p:layoutUnit position="center">
				<p:menubar>
					<p:submenu label="Administração" icon="ui-icon-document">
						<p:submenu label="Cadastrar" icon="ui-icon-contact">
						<p:menuitem value="Tipo de Registro" url="#" />
							<p:menuitem value="Grupo Execuçao" url="#" />							
						</p:submenu>
						<p:menuitem value="Inserir Script" url="cadastroScript.jsf" />
						<p:separator />
						<p:menuitem value="Quit" url="#" />
					</p:submenu>
				</p:menubar>
				<p:panel id="panel" header="Analise de Incidentes"
					style="margin-bottom:10px;">
					<h:panelGrid columns="2">
						<h:outputLabel for="numChamado" value="Número do Chamado : " />
						<p:inputText id="numChamado" value="#{incidentMB.numChamado}" />

						<h:outputLabel for="txtCidade" value="Cidade : " />
						<p:autoComplete size="80" scrollHeight="300"
							value="#{incidentMB.cidadeSelecionada}" id="txtCidade"
							completeMethod="#{incidentMB.completeCidades}" var="p" itemLabel="#{p}"
							dropdown="true" itemValue="#{p}"
							converter="cidadeOperadoraConverter" forceSelection="true"
							minQueryLength="3">

						</p:autoComplete>

						<h:outputLabel for="tipoRegistro" value="Tipo de Registro: " />
						<p:autoComplete size="80" scrollHeight="300"
							value="#{incidentMB.tipoRegistro}" id="tipoRegistro"
							completeMethod="#{incidentMB.completeTiposRegistro}" var="p" itemLabel="#{p}"
							dropdown="true" itemValue="#{p}"
							converter="tipoRegistroConverter" forceSelection="true"
							minQueryLength="3">
						</p:autoComplete>
						

						<h:outputLabel for="numRegistro" value="Valor : " />
						<p:inputText id="numRegistro" value="#{incidentMB.vlrRegistro}" />

						<h:outputLabel for="ajax" value="Acao : " />

						<p:commandButton value="Adicionar +" update="panel" id="ajax"
							actionListener="#{incidentMB.populateIncidentsList(event)}" />
						<p:fileUpload
							fileUploadListener="#{fileUploadController.handleFileUpload}"
							mode="advanced" update="messages"  sizeLimit="100000"
							allowTypes="/(\.|\/)(xls|xlsx|csv)$/" label="Importar"/>

<p:growl id="messages" showDetail="true"/>  

						<h:outputLabel for="basic" value="Listagem : " />
						<p:dataTable id="basic" var="incident"
							value="#{incidentMB.lstIncidents}" paginator="true" rows="5"
							paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
							rowsPerPageTemplate="5,10,15">  >
							<p:column id="chamadoHeader">
								<f:facet name="header">
                    				Chamado
           						 </f:facet>
								<h:outputText value="#{incident.numChamado}" />
							</p:column>

							<p:column id="tipoRegistroHeader">
								<f:facet name="header">
                    				Tipo de Registro
           						 </f:facet>
								<h:outputText value="#{incident.tipoRegistro}" />
							</p:column>

							<p:column id="ValorHeader">
								<f:facet name="header">
                    				Registro
            					</f:facet>
								<h:outputText value="#{incident.vlrRegistro}" />
							</p:column>

							<p:column style="width:40px">
								<h:panelGrid columns="3" styleClass="actions" cellpadding="2">
									<p:commandButton id="selectButton" update="basic"
										icon="ui-icon-trash" title="View">
									</p:commandButton>
									
								</h:panelGrid>
							</p:column>
							<p:column style="width:40px">
								<h:panelGrid columns="3" styleClass="actions" cellpadding="2">
									<p:commandButton id="selectButton1" update="basic"
										icon="ui-icon-play" title="View">
									</p:commandButton>
								</h:panelGrid>
							</p:column>
							<f:facet name="footer">
								<p:commandButton id="viewButton" value="Analisar Todos"
									onclick="processVar.show();"
									oncomplete="processVar.hide();dlg2.show();" ajax="true"
									icon="ui-icon-play" update="basic"
									actionListener="#{incidentMB.analyseIncidents(event)}" />
							</f:facet>
						</p:dataTable>
					</h:panelGrid>


				</p:panel>
				<p:dialog id="modalDialog" header="Informacao da Analise"
					widgetVar="dlg2" height="500" width="500">					
						<p:dataList value="#{incidentMB.lstResultAnalysis}" var="result"
							itemType="disc">  
    						#{result.descProblemaEncontrado}, 
    						<p:lightBox iframe="true">
							<h:outputLink value="#{result.urlToDocumentation}"
								title="PrimeFaces HomePage">
								<h:outputText value="Documentacao" />
							</h:outputLink>
						</p:lightBox>
						,<h:outputLink target="_blank" value="#{result.urlToDocumentation}">Documentacao</h:outputLink>
					</p:dataList>					
				</p:dialog>
		</p:layoutUnit>
	</p:layout>

	<p:dialog header="Informativo" closable="false" modal="true"
		resizable="false" id="processId" widgetVar="processVar">
        Processando....
     </p:dialog>
</h:form>
     
</h:body>
</html>